package com.example.h9iserver.common;

/**
 * @Description:
 * @Author: Dabs
 * @Date: 2020/6/2 15:17
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMessage;

    protected Boolean success;

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public BusinessException() {
        super();
    }

    public BusinessException(ExceptionCodeConstants exceptionCodeConstants){
        this.errorCode = exceptionCodeConstants.getErrorCode().toString();
        this.errorMessage = exceptionCodeConstants.getErrorMessage();
        this.success = exceptionCodeConstants.getSuccess();
    }

    public BusinessException(ExceptionCodeConstants exceptionCodeConstants, String message){
        this.errorCode = exceptionCodeConstants.getErrorCode().toString();
        this.errorMessage = message;
        this.success = exceptionCodeConstants.getSuccess();
    }

    public BusinessException(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMessage = errorMsg;
        this.success = false;
    }

    public BusinessException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode + " " + errorMsg, cause);
        this.errorCode = errorCode;
        this.errorMessage = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMessage;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMessage = errorMsg;
    }

}
